Skip to content

feat: add mobile Hermes CDP support and hermes_targets tool#37

Open
cryptotavares wants to merge 2 commits into
add-mobile-driverfrom
cryptotavares/add-hermes-cdp
Open

feat: add mobile Hermes CDP support and hermes_targets tool#37
cryptotavares wants to merge 2 commits into
add-mobile-driverfrom
cryptotavares/add-hermes-cdp

Conversation

@cryptotavares

Copy link
Copy Markdown
Collaborator

What is the current state of things and why does it need to change?

The cdp tool was browser-only: it opened a Playwright CDP session against the active page and enforced a hard-coded blocklist of destructive Chrome methods. There was no way to reach the React Native Hermes JS runtime on a mobile session, so agents driving iOS/Android had no raw-CDP escape hatch and no way to inspect which Hermes debug targets Metro exposes. Platform gating (browser-only tool checks) was also duplicated between the HTTP route handler and the run_steps batch executor, so the two paths could drift on error code/message and there was no concept of a mobile-only tool.

What is the solution your changes offer and how does it work?

  • Unified cdp toolcdp now dispatches through the active platform driver instead of talking to Playwright directly. On browser it targets the page's Chrome CDP session (full Runtime/DOM/Network/Page surface); on mobile it targets the app's Hermes JS runtime via Metro's inspector proxy (@metamask/device-mcp), exposing only the JS-engine subset (Runtime, Debugger, Log, HeapProfiler). Each driver owns its own destructive-method blocklist, so cdp is no longer classified as browser-only. Optional metroPort / appId inputs are mobile-only (ignored on browser).
  • New hermes_targets tool (mobile only) — lists and diagnoses the debuggable Hermes targets Metro exposes, reporting which target would be chosen or why selection is ambiguous, with an all flag to bypass the appId filter and discover the real appId.
  • Shared platform gating — extracted a single checkPlatformGate helper used by both the HTTP route handler and the run_steps executor, plus isMobileOnlyTool, so browser-only / mobile-only gating cannot drift on error code or message. An absent platform driver is treated as "not mobile", so mobile-only tools are gated off.
  • Types, schemas & errors — added CdpOutcome, HermesTargetsResult, and related types; Zod schemas for the new inputs; and MM_HERMES_FAILED / MM_HERMES_NOT_AVAILABLE / MM_TOOL_NOT_SUPPORTED_ON_PLATFORM error codes (underlying HERMES_* codes are preserved in the message).
  • Docs — README and SKILL.md updated with a Browser vs Mobile (Hermes) CDP comparison and the new tool/CLI reference.

Full unit coverage added for the driver dispatch, the hermes_targets tool, platform gating, and the batch/route integration paths.

Note: This PR is stacked on add-mobile-driver (#36) and targets that branch. It should be merged after #36 lands (and retargeted to main if #36 is rebased/merged first).

Links

Dispatch the cdp tool through the platform driver so it targets the
Chrome CDP session on browser and the React Native Hermes runtime via
Metro on mobile, with each driver owning its own destructive-method
blocklist. Add a mobile-only hermes_targets tool to list and diagnose
debuggable Hermes targets.

Extract platform gating into a shared checkPlatformGate helper used by
both the HTTP route handler and the run_steps batch executor, and add
isMobileOnlyTool alongside the existing browser-only gating so the two
paths cannot drift on error code or message.
@cryptotavares cryptotavares requested a review from a team as a code owner July 9, 2026 07:59
Wire up the device-mcp encode option so mobile screenshots can return
base64 data when includeBase64 is requested, instead of always empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant